package com.cspg.ssss.job;

import com.cspg.ssss.domain.CheckBatchInst;
import com.cspg.ssss.service.CheckBatchService;
import com.cspg.ssss.service.ProblemGradeService;
import com.cspg.ssss.service.ProblemService;
import com.cspg.ssss.util.DateUtil;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

public class DailyJob extends QuartzJobBean {
    private static final Logger log = LoggerFactory.getLogger(DailyJob.class);

    @Autowired
    CheckBatchService checkBatchService;

    @Autowired
    ProblemGradeService problemGradeService;

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        log.info("DailyJob ......++ ");
        //根据配置启动批次
        CheckBatchInst inst = new CheckBatchInst();
        inst.setCheck_type(0);
        inst.setStart_date(DateUtil.getCurrentDate());
        checkBatchService.createCheckBatchInst(inst);
        inst.setCheck_type(1);
        checkBatchService.createCheckBatchInst(inst);

        //切换阶段
        problemGradeService.setNextStage(0);
        problemGradeService.setNextStage(1);

        log.info("DailyJob ......end ++ ");
    }
}
